package graphics.effects;
import main.Config;
import tools.Log;
import tools.Point;
import graphics.system.Framebuffer;
import graphics.system.Resolution;
/**
 * Contains several layers (shadow, warp, particles...)
 * 
 * @author jonathan
 * 
 */
public class Layer {
	public static int quality = 1;
	public static Framebuffer warp;
	public static Framebuffer shadow;
	public static Framebuffer particles;
	public static Framebuffer colormap;
	// public static Framebuffer mapimg;
	public static void init() {
		float x = Config.RESOLUTION.x;
		float y = Config.RESOLUTION.y;
		warp = new Framebuffer(new Point(256,256), false, false);
		shadow = new Framebuffer(Config.RESOLUTION.div(Config.SHADER_QUALITY), true, true);
		particles = new Framebuffer(Config.RESOLUTION.div(Config.SHADER_QUALITY), false, false);
		// mapimg = new Framebuffer(new Point(128,128), false, false);
		colormap = new Framebuffer(Config.RESOLUTION, false, false);
		float fbsize = (x / Config.SHADER_QUALITY * y / Config.SHADER_QUALITY) * 3 + x * y;
		fbsize = (float) (fbsize * 3) / 1024.0f / 1000.0f;
		Log.g("Layer(Framebuffer) initialized: " + fbsize + " mb");
	}
	public static void resize(int w, int h) {
		Log.g("new windowsize:" + w + "x" + h);
		/*if (warp != null)
			warp.resize(w / Config.SHADER_QUALITY, h / Config.SHADER_QUALITY);
		*/
		if (shadow != null)
			shadow.resize(w / Config.SHADER_QUALITY, h / Config.SHADER_QUALITY);
		if (particles != null)
			particles.resize(w / Config.SHADER_QUALITY, h / Config.SHADER_QUALITY);
		if (colormap != null)
			colormap.resize(w, h);
		float fbsize = (w / Config.SHADER_QUALITY * h / Config.SHADER_QUALITY) * 3 + w * h;
		fbsize = (float) (fbsize * 3) / 1024.0f / 1000.0f;
		Log.g("Framebuffer reinitialized: " + fbsize + " mb");
	}
}
